/*
 *
 *
 */

#ifndef GKT_LED_H
#define GKT_LED_H

#include "gkt_types.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef GKT_CONFIG_LED_DESC_TABLE

#define GKT_LED_ID(_name)	GKT_LED_ID_##_name

#define GKT_LED_DESC(_name, _pin, _on_level, _current_ds)	\
	GKT_LED_ID(_name)

enum {
	GKT_CONFIG_LED_DESC_TABLE,
	GKT_LED_ID_MAX
};

#if !defined(GKT_CONFIG_LED_FLICKER_DISABLE) || !GKT_CONFIG_LED_FLICKER_DISABLE
#define GKT_LED_FLICKER_ENABLE	1
#else
#define GKT_LED_FLICKER_ENABLE	0
#endif

typedef enum {
	GKT_LED_FLICKER_ST_DONE = 0,
	GKT_LED_FLICKER_ST_MAX
} gkt_led_flicker_state_e;

typedef void (*gkt_led_flicker_notify_fn)(gkt_led_flicker_state_e state, 
				uint32_t private_data);

#define GKT_LED_FLICKER_F_END_RESUME_ORIGIN	(1U << 0)
#define GKT_LED_FLICKER_F_END_LAST_FRAME	(1U << 1)
#define GKT_LED_FLICKER_F_END_LIGHTEN_ALL	(1U << 2)
#define GKT_LED_FLICKER_F_END_LIGHTEN_NONE	(1U << 3)
#define GKT_LED_FLICKER_F_REVERSE_BACK	(1U << 8)

typedef struct {
	uint32_t	flags;

	uint32_t	cycles;
	uint32_t	frame_time;	/* duration time of one frame */
	uint32_t	frame_nums;	/* frame nums of one cycle */
	const uint32_t	*frame_led_bits;
	uint32_t	all_led_bits;

	uint32_t	private_data;
	gkt_led_flicker_notify_fn	notify_fn;
} gkt_led_flicker_params_s;

int gkt_led_init(void);
void gkt_led_lighten(uint32_t off_led_bits, uint32_t on_led_bits);
#if GKT_LED_FLICKER_ENABLE
int gkt_led_flicker(const gkt_led_flicker_params_s *params);
#else
#define gkt_led_flicker(params)	do { gkt_unused(params); } while (0)
#endif
void gkt_led_standby(void);

#else

#define GKT_LED_ID(name)	0
#define GKT_LED_FLICKER_ENABLE	0

#define gkt_led_init()	GKT_SUCCESS
#define gkt_led_lighten(off_led_bits, on_led_bits)	\
	do { gkt_unused(off_led_bits); gkt_unused(on_led_bits); } while (0)
#define gkt_led_flicker(params)	do { gkt_unused(params); } while (0)
#define gkt_led_standby()	do {} while(0)

#endif

#ifdef __cplusplus
}
#endif

#endif	/* GKT_LED_H */

